package com.atguigu.a_principle.p1single.v2;

public class SingleResponsebility {
    public static void main(String[] args) {
        Vehicle1 vehicle1 = new Vehicle1();
        Vehicle2 vehicle2 = new Vehicle2();
        Vehicle3 vehicle3 = new Vehicle3();
        vehicle1.run("cars");
        vehicle2.run("airplane");
        vehicle3.run("steamer");
    }
}

/*
方案 2 的分析
1. 遵守单一职责原则
2. 但是这样做的改动很大，即将类分解，同时修改客户端
3. 改进：直接修改 Vehicle 类，改动的代码会比较少=>方案 3
*/
class Vehicle1 {
    /**
     * 一个方法执行多个任务，职责不清晰
     *
     * @param name
     */
    public void run(String name) {
        System.out.println(name + " runs on the road");
    }
}
class Vehicle2 {
    /**
     * 一个方法执行多个任务，职责不清晰
     *
     * @param name
     */
    public void run(String name) {
        System.out.println(name + " runs on the air");
    }
}

class Vehicle3 {
    /**
     * 一个方法执行多个任务，职责不清晰
     *
     * @param name
     */
    public void run(String name) {
        System.out.println(name + " runs on the water");
    }
}